package br.com.docgest.engine;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JTextField;

public class keyListenerFunctions {

    public void toUppercaseTherm(JTextField textField) {
        textField.addKeyListener(new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {
                JTextField campo = (JTextField) e.getSource();
                int posicaoCursor = campo.getCaretPosition();
                campo.setText(campo.getText().toUpperCase());
                if (posicaoCursor != campo.getCaretPosition()) {
                    campo.setCaretPosition(posicaoCursor);
                }                
            }

            @Override
            public void keyPressed(KeyEvent e) {
            }

            @Override
            public void keyReleased(KeyEvent e) {
            }

        });

    }

}
